home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / PROTO.ICN < prev    next >
Text File  |  1992-11-26  |  3KB  |  212 lines

  1. ############################################################################
  2. #
  3. #    File:     proto.icn
  4. #
  5. #    Subject:  Program to show Icon syntactic forms
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     June 10, 1988
  10. #
  11. ###########################################################################
  12. #
  13. #     This program doesn't "do" anything.  It just contains an example of
  14. #  every syntactic form in Version 7 of Icon (or close to it).  It might
  15. #  be useful for checking programs that process Icon programs.  Note, however,
  16. #  that it does not contain many combinations of different syntactic forms.
  17. #
  18. ############################################################################
  19. #
  20. #  Program note:
  21. #
  22. #     This program is divided into procedures to avoid overflow with
  23. #  default values for Icon's translator and linker.
  24. #
  25. ############################################################################
  26. #
  27. #  Links: options
  28. #
  29. #  Requires:  co-expressions
  30. #
  31. ############################################################################
  32.  
  33. link options
  34.  
  35. record three(x,y,z)
  36. record zero()
  37. record one(z)
  38.  
  39. global line, count
  40.  
  41. procedure main()
  42.    expr1()
  43.    expr2()
  44.    expr3()
  45.    expr4(1,2)
  46.    expr4{1,2}
  47.    expr5(1,2,3,4)
  48. end
  49.  
  50. procedure expr1()
  51.    local x, y, z
  52.    local i, j
  53.    static e1
  54.  
  55.    initial e1 := 0
  56.  
  57.    exit()            # get out before there's trouble
  58.  
  59.    ()
  60.    {}
  61.    ();()
  62.    []
  63.    [,]
  64.    x.y
  65.    x[i]
  66.    x[i:j]
  67.    x[i+:j]
  68.    x[i-:j]
  69.    (,,,)
  70.    x(,,,)
  71.    not x
  72.    |x
  73.    !x
  74.    *x
  75.    +x
  76.    -x
  77. end
  78.  
  79. procedure expr2()
  80.    local x, i, y, j, c1, c2, s1, s2, a2, k, a1
  81.  
  82.    .x
  83.    /x
  84.    =x
  85.    ?x
  86.    \x
  87.    ~x
  88.    @x
  89.    ^x
  90.    x \ i
  91.    x @ y
  92.    i ^ j
  93.    i * j
  94.    i / j
  95.    i % j
  96.    c1 ** c2
  97.    i + j
  98.    i - j
  99.    c1 ++ c2
  100.    c1 -- c2
  101.    s1 || s2
  102.    a1 ||| a2
  103.    i < j
  104.    i <= j
  105.    i = j
  106.    i >= j
  107.    i > j
  108.    i ~= j
  109.    s1 << s2
  110.    s1 == s2
  111.    s1 >>= s2
  112.    s1 >> s2
  113.    s1 ~== s2
  114.    x === y
  115.    x ~=== y
  116.    x | y
  117.    i to j
  118.    i to j by k
  119.    x := y
  120.    x <- y
  121.    x :=: y
  122.    x <-> y
  123.    i +:= j
  124.    i -:= j
  125.    i *:= j
  126. end
  127.  
  128. procedure expr3()
  129.    local i, j, c1, c2, s1, s2, a1, a2, x, y, s
  130.  
  131.    i /:= j
  132.    i %:= j
  133.    i ^:= j
  134.    i <:= j
  135.    i <=:= j
  136.    i =:= j
  137.    i >=:= j
  138.    i ~=:= j
  139.    c1 ++:= c2
  140.    c1 --:= c2
  141.    c1 **:= c2
  142.    s1 ||:= s2
  143.    s1 <<:= s2
  144.    s1 <<=:= s2
  145.    s1 ==:= s2
  146.    s1 >>=:= s2
  147.    s1 >>:= s2
  148.    s1 ~==:= s2
  149.    s1 ?:= s2
  150.    a1 |||:= a2
  151.    x ===:= y
  152.    x ~===:= y
  153.    x &:= y
  154.    x @:= y
  155.    s ? x
  156.    x & y
  157.    create x
  158.    return
  159.    return x
  160.    suspend x
  161.    suspend x do y
  162.    fail
  163. end
  164.  
  165. procedure expr4()
  166.    local e1, e2, e, x, i, j, size, s, e3, X_
  167.  
  168.    while e1 do break
  169.    while e1 do break e2
  170.    while e1 do next
  171.    case e of {
  172.      x:   fail
  173.      (i > j) | 1    :  return
  174.      }
  175.    case size(s) of {
  176.      1:   1
  177.      default:  fail
  178.      }
  179.    if e1 then e2
  180.    if e1 then e2 else e3
  181.    repeat e
  182.    while e1
  183.    while e1 do e2
  184.    until e1
  185.    until e1 do e2
  186.    every e1
  187.    every e1 do e2
  188.    x
  189.    X_
  190.    &cset
  191.    &null
  192.    "abc"
  193.    "abc_
  194.     cde"
  195.    'abc'
  196.    'abc_
  197.     cde'
  198.    "\n"
  199.    "^a"
  200.    "\001"
  201.    "\x01"
  202.    1
  203.    999999
  204.    36ra1
  205.    3.5
  206.    2.5e4
  207.    4e-10
  208. end
  209.  
  210. procedure expr5(a,b,c[])
  211. end
  212.